package com.lookme.lmtool.cracker.filter.effect;

import com.jhlabs.image.ChromeFilter;
import com.jhlabs.image.ContourFilter;
import com.jhlabs.image.EdgeFilter;
import com.jhlabs.vecmath.Color4f;
import com.lookme.lmtool.cracker.CrackerConstants;
import com.lookme.lmtool.cracker.annotation.FilterAnnotation;
import com.lookme.lmtool.cracker.annotation.ParamAnnotation;
import com.lookme.lmtool.cracker.filter.AbstractFilter;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

import java.awt.image.BufferedImageOp;

@FilterAnnotation(groupName = CrackerConstants.FILTER_GROUP_NAME_EFFECT,name="镶边",filterClass = ChromeFilter.class)
public class FilterChrome extends AbstractFilter {
    @XStreamAsAttribute
    @ParamAnnotation(name = "数量", desc = "数量",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.05,max = 100)
    float amount = 0.5f;
    @XStreamAsAttribute
    @ParamAnnotation(name = "曝光度", desc = "曝光度",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.05,max=5,blockIncrement = 5,majorTickUnit=1,minorTickCount = 3)
    float exposure = 1.0f;

    @XStreamAsAttribute
    @ParamAnnotation(name = "高度", desc = "凹凸高度",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.05,max=5,blockIncrement = 5,majorTickUnit=1,minorTickCount = 3)
    private float bumpHeight=1.0f;
    @XStreamAsAttribute
    @ParamAnnotation(name = "柔和度", desc = "凹凸柔和度",inputType = ParamAnnotation.InputType.Slider,width = 300,amountToStepBy = 0.05,max = 50)
    private float bumpSoftness=5.0f;

    @XStreamAsAttribute
    @ParamAnnotation(name = "扩散颜色", desc = "扩散颜色",inputType = ParamAnnotation.InputType.ColorPicker,margin = {0,50,0,0})
    int diffuseColor=0x000000;

    @Override
    public BufferedImageOp getFilter() {
        ChromeFilter filter= new ChromeFilter();
        filter.setAmount(amount);
        filter.setExposure(exposure);
        filter.setBumpHeight(bumpHeight);
        filter.setBumpSoftness(bumpSoftness);
        filter.setDiffuseColor(diffuseColor );
        return filter;
    }
}
